//
//  PCBankCardManager.m
//  PromotionCode
//
//  Created by uuu9 on 2017/12/11.
//  Copyright © 2017年 My. All rights reserved.
//

#import "PCBankCardManager.h"
#import "PCBankModel.h"

@implementation PCBankCardManager

+(void)addBankCardWithUserID:(NSString *)uid andRealName:(NSString *)realName andSessionID:(NSString *)sessionid andCard:(NSString *)card andBank:(NSString *)bank andCompletionHandle:(void (^)(BankModel *, NSError *))complete{
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kBankCard]
           parameters:[NSString stringWithFormat:@"type=set&userid=%@&card=%@&realname=%@&bank=%@&sessionid=%@",uid,card,realName,bank,sessionid]
    completionHandler:^(id responseObj, NSError *error) {
        PCBankModel *model = [PCBankModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model.output,error);
    }];
    
}
+(void)deleteBankCardWithUserID:(NSString *)uid andSessionID:(NSString *)sessionid andCompletionHandle:(void (^)(BankModel *, NSError *))complete{
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kBankCard]
           parameters:[NSString stringWithFormat:@"type=delete&userid=%@&sessionid=%@",uid,sessionid]
    completionHandler:^(id responseObj, NSError *error) {
        PCBankModel *model = [PCBankModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model.output,error);
    }];
    
}
+ (void)getBankCardWithCard:(NSString *)card andUserID:(NSString *)uid andSessionID:(NSString *)sessionid  andCompletionHandle:(void (^)(BankModel *, NSError *))complete{
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kBankCard]
           parameters:[NSString stringWithFormat:@"type=bank&card=%@&sessionid=%@&userid=%@",card,sessionid,uid]
    completionHandler:^(id responseObj, NSError *error){
        PCBankModel *model = [PCBankModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model.output,error);
    }];
}


@end
